/*
	Copyright (c) 2009-2011, Stefan Webb.

	This file is part of SimpleML. Please read the file "license.txt", 
	which contains the conditions under which this software is distributed.
*/

/*!
	\file hasstate.h
	\author Stefan Webb
	\brief Definition of HasState class
*/

#ifndef HASSTATE_H
#define HASSTATE_H

/*! \brief A class having a state, the type of which can be varied since it is
	a template. */
template <class T = bool>
class HasState
{
public:
	/*! \brief Default constructor. */
	// NOTE: Subclass should initialize own state.
	//HasState();

	/*! \brief Set the class's state.
		\param state New state of class. */
	// NOTE: Would it be a good idea to return the old state?
	void setState(T state);

	/*! \brief Get the class's state.
		\return Class's state. */
	T getState();

protected:
	/*! \brief State of class. */
	T state_;
};

/* Set the class's state. */
template <class T>
void HasState<T>::setState(T state)
{
	state_ = state;
}

/* Get the class's state. */
template <class T>
T HasState<T>::getState()
{
	return state_;
}

#endif